<?php
$dis_id=3;
include("../../inc/conn.inc");
$check_rs=@mysql_query("select id,m_type,m_jifen,m_rz_ok from member where id='".$_COOKIE['user_id']."'");
$check_row=@mysql_fetch_array($check_rs);
//if(!$check_row[m_rz_ok]){
  //  echo "<script>alert('您还没有上传您的认证证件,或审核中');location='../company/rz.php';/script>";
//}
if($_POST[act_tj]){
   $n_rs2=@mysql_query("select count(id) from pf_list where member_id='".$_COOKIE['user_id']."'");
   $num=@mysql_result($n_rs2,0);
   @mysql_free_result($n_rs2);
   	    $c_rs_1=mysql_query("select * from pf_catalog where id='$_POST[catalog_1]'");
	    $c_row_1=mysql_fetch_array($c_rs_1);
	    $c_rs_2=mysql_query("select * from pf_catalog where id='$_POST[catalog_2]'");
	    $c_row_2=mysql_fetch_array($c_rs_2);
		$c_rs_3=mysql_query("select * from pf_catalog where id='$_POST[catalog_3]'");
	    $c_row_3=mysql_fetch_array($c_rs_3);
		
	    $catalog_1=($_POST[catalog_1])?$_POST[catalog_1]:0;
	    $catalog_2=($_POST[catalog_2])?$_POST[catalog_2]:0;
		$catalog_3=($_POST[catalog_3])?$_POST[catalog_3]:0;
		$is_huodong=($_POST[is_huodong])?$_POST[is_huodong]:0;
		
if($check_row[m_type]==3){
	  if($num>=10){  
	    echo "<script>alert('您只能发布10条信息。');location='index.php';</script>";
	  }else{

	    @mysql_query("insert into pf_list (member_id,p_title,catalog_id1,catalog_1,catalog_id2,catalog_2,catalog_id3,catalog_3,p_pinpai,p_xinghao,p_price,p_shuliang,p_guige,p_baozhuang,p_cailiao,p_chandi,p_renzheng,p_jiaohu,p_paytype,p_yunshu,p_yunfei,picture,p_info,is_huodong,hd_price,hd_time,p_addtime) values ('".$_COOKIE['user_id']."','$_POST[p_title]','$catalog_1','$c_row_1[cat_name]','$catalog_2','$c_row_2[cat_name]','$catalog_3','$c_row_3[cat_name]','$_POST[pinpai]','$_POST[xinghao]','$_POST[price]','$_POST[shuliang]$_POST[shuliang2]','$_POST[guige]','$_POST[baozhuang]','$_POST[cailiao]','$_POST[chandi]','$_POST[renzheng]','$_POST[jiaohu]','$_POST[paytype]','$_POST[yunshu]','$_POST[yunfei]','$_POST[picture]','$_POST[info]','$is_huodong','$_POST[hd_price]','$_POST[hd_time]','".date("Y-m-d H:i:s")."')");
	    echo "<script>alert('发布成功,继续发布');location='add.php';</script>";
	  }
}else{

	    @mysql_query("insert into pf_list (member_id,p_title,catalog_id1,catalog_1,catalog_id2,catalog_2,catalog_id3,catalog_3,p_pinpai,p_xinghao,p_price,p_shuliang,p_guige,p_baozhuang,p_cailiao,p_chandi,p_renzheng,p_jiaohu,p_paytype,p_yunshu,p_yunfei,picture,p_info,is_huodong,hd_price,hd_time,p_addtime) values ('".$_COOKIE['user_id']."','$_POST[p_title]','$catalog_1','$c_row_1[cat_name]','$catalog_2','$c_row_2[cat_name]','$catalog_3','$c_row_3[cat_name]','$_POST[pinpai]','$_POST[xinghao]','$_POST[price]','$_POST[shuliang]$_POST[shuliang2]','$_POST[guige]','$_POST[baozhuang]','$_POST[cailiao]','$_POST[chandi]','$_POST[renzheng]','$_POST[jiaohu]','$_POST[paytype]','$_POST[yunshu]','$_POST[yunfei]','$_POST[picture]','$_POST[info]','$_POST[is_huodong]','$_POST[hd_price]','$_POST[hd_time]','".date("Y-m-d H:i:s")."')");
		
       $product_id=@mysql_result(@mysql_query("select last_insert_id() from pf_list where member_id='".$_COOKIE['user_id']."'"),0); 
       
	   echo "<script>alert('钻石会员对该信息可以发10张宣传图片');location='img.php?id=$product_id';</script>";
}  
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>会员中心-三帝贸易网</title>
<link href="../css/css.css" rel="stylesheet" type="text/css" />
</head>
<script type="text/javascript" src="../js/left.js" charset="gb2312"></script>
<script type='text/javascript' src="../js/time.js" charset="gb2312"></script>

<body>
<script language = "JavaScript">    
<?php
$rs1=mysql_query("select * from pf_catalog order by id asc");
?>
var onecount;
onecount=0;
subcat=new Array();
<?php
$count1=0;
while($row1=mysql_fetch_array($rs1)){?>
subcat[<?=$count1?>]=new Array("<?=$row1[cat_name]?>","<?=$row1[cat_id]?>","<?=$row1[id]?>");
<?php
$count1=$count1+1;}?>
onecount=<?=$count1?>;  
//联动函数    
function changelocation(locationid){   
   document.form1.catalog_2.length=0;     
   var locationid=locationid;   
   var i;   
   for(i=0;i<onecount;i++){   
       if(i==0){     
          document.form1.catalog_2.options[document.form1.catalog_2.length]=new Option("--二级分类--","");
		  }   
       if(subcat[i][1]==locationid){     
          document.form1.catalog_2.options[document.form1.catalog_2.length]=new Option(subcat[i][0],subcat[i][2]);   
          }                   
    }   
}

function changelocation2(locationid2)   
{   
document.form1.catalog_3.length=0;     
var locationid2=locationid2;   
var i2;   
for (i2=0;i2<onecount;i2++){   
     if(i2==0){     
         document.form1.catalog_3.options[document.form1.catalog_3.length]=new Option("--三级分类--","");     
         }   
     if(subcat[i2][1]==locationid2){     
         document.form1.catalog_3.options[document.form1.catalog_3.length]=new Option(subcat[i2][0],   subcat[i2][2]);   
         }                   
     }   
}
</script>
<div id="mian">
<?php include("../inc/top.php");?>
<div class="top1"><span>您当前位置：<a href="../index.php" class="dh">会员助手</a> &gt;&gt; 批发市场 &gt;&gt; 发布批发市场</span></div>
<div class="left">
<?php include("../inc/left.php");?>
</div>
<div class="right">
<TABLE cellSpacing="0" cellPadding="0" width="100%" border="0">
   <TR>
     <TD height="40" bgcolor="#EFF6FF" style="font-size:18px;font-weight:bold;padding-left:8px;">发布批发市场信息</TD>
   </TR>
</TABLE>
<br>
<TABLE width="100%" border="0" cellpadding="0" cellSpacing="1" bgcolor="#C1DCF5">
        <TBODY>
        <form method="post" action="" name="form1" onSubmit="return checkform()">
          <TR>
            <td width="17%" height="25" align="center" bgcolor="#EFF6FF">标题&nbsp;<font color="#FF0000">*</font></td>
            <TD width="83%" bgcolor="#F9F9F9" style="padding-left:4px;"><input name="p_title" id="p_title" type="text" size="50" maxlength="120"></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">目录<span style="padding-left:4px;line-height:35px;">&nbsp;<font color="#FF0000">*</font></span></td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;line-height:35px;"><select name="catalog_1" id="catalog_1" onChange="changelocation(document.form1.catalog_1.options[document.form1.catalog_1.selectedIndex].value)">
 <option value="">--选择大类--</option>   
<?php
$rrs=mysql_query("select id,cat_name from pf_catalog where cat_id=0 order by id asc");    
while($rrow=mysql_fetch_array($rrs)){   
?>     
 <option value="<?=$rrow[id]?>"><?=$rrow[cat_name]?></option><?php }?>
</select>&nbsp;<select name="catalog_2" id="catalog_2" onFocus="changelocation(document.form1.catalog_1.options[document.form1.catalog_1.selectedIndex].value)">
  <option value="">--选择二级分类--</option>
</select>&nbsp;<select name="catalog_3" id="catalog_3" onFocus="changelocation2(document.form1.catalog_2.options[document.form1.catalog_2.selectedIndex].value)">   
  <option value="" selected>--选择三级分类--</option>
</select></TD>
          </TR>		  
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">描述&nbsp;<font color="#FF0000">*</font></td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><textarea name="info" id="info" cols="70" rows="20"></textarea><br>
            <font color="#FF0000">警告：</font>请不要添加<font color="#FF0000">公司电话</font>和贵<font color="#FF0000">公司网址</font>，否则我们直接删除该信息。<br></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">图片</td>
            <TD bgcolor="#F9F9F9" style="padding:4px;line-height:30px;"><input name="picture" id="picture" type="text" size="35" maxlength="100">&nbsp;&nbsp;<input name="button" type="button" onClick="window.open ('../upfile.php', 'newwindow', 'height=50, width=400, top=250, left=250, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no')" value="上传图片">
              (建议图片长宽：270*240)<br>
              <input type="button" onClick="window.open ('/member/photo/info.php', 'newwindow', 'height=500, width=600, top=0, left=250, toolbar=no, menubar=no, scrollbars=yes, resizable=no,location=no, status=no')" value="选择已上传的图片"></TD>
          </TR>
		  <TR>
            <td height="25" colspan="2" align="left" bgcolor="#EFF6FF"><STRONG>参数<font color="#FF0000">(请认真完善以下资料，否则您的信息将直接删除)</font></STRONG></td>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">商品品牌&nbsp;<font color="#FF0000">*</font></td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input name="pinpai" id="pinpai" type="text" size="20" maxlength="20"></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">商品型号&nbsp;<font color="#FF0000">*</font></td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input name="xinghao" id="xinghao" type="text" size="20" maxlength="20"></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">批发价格&nbsp;<font color="#FF0000">*</font></td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input name="price" id="price" type="text" size="20" maxlength="20">
            元<font color="red">（请写实际批发价格）</font></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">起批数量&nbsp;<font color="#FF0000">*</font></td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input name="shuliang" id="shuliang" type="text" size="20" maxlength="20">&nbsp;<select name="shuliang2">
                <OPTION value="">--请选择--</OPTION>
                <OPTION value="/台">/台</OPTION>
                <OPTION value="/粒">/粒</OPTION>
                <OPTION value="/座">/座</OPTION>
                <OPTION value="/辆">/辆</OPTION>
                <OPTION value="/只">/只</OPTION>
                <OPTION value="/支">/支</OPTION>
                <OPTION value="/枝">/枝</OPTION>
                <OPTION value="/架">/架</OPTION>
                <OPTION value="/头">/头</OPTION>
                <OPTION value="/张">/张</OPTION>
                <OPTION value="/块">/块</OPTION>
                <OPTION value="/片">/片</OPTION>
                <OPTION value="/匹">/匹</OPTION>
                <OPTION value="/件">/件</OPTION>
                <OPTION value="/根">/根</OPTION>
                <OPTION value="/条">/条</OPTION>
                <OPTION value="/把">/把</OPTION>
                <OPTION value="/卷">/卷</OPTION>
                <OPTION value="/副">/副</OPTION>
                <OPTION value="/幅">/幅</OPTION>
                <OPTION value="/双">/双</OPTION>
                <OPTION value="/一打">/一打</OPTION>
                <OPTION value="/份">/份</OPTION>
                <OPTION value="/套">/套</OPTION>
                <OPTION value="/棵">/棵</OPTION>
                <OPTION value="/箱">/箱</OPTION>
                <OPTION value="/袋">/袋</OPTION>
                <OPTION value="/盒">/盒</OPTION>
                <OPTION value="/包">/包</OPTION>
                <OPTION value="/捆">/捆</OPTION>
                <OPTION value="/筐">/筐</OPTION>
                <OPTION value="/瓶（罐）">/瓶（罐）</OPTION>
                <OPTION value="/毫米">/毫米</OPTION>
                <OPTION value="/厘米">/厘米</OPTION>
                <OPTION value="/米">/米</OPTION>
                <OPTION value="/千米">/千米</OPTION>
                <OPTION value="/英寸">/英寸</OPTION>
                <OPTION value="/英尺">/英尺</OPTION>
                <OPTION value="/加仑(英)">/加仑 (英)</OPTION>
                <OPTION value="/加仑(美)">/加仑 (美)</OPTION>
                <OPTION value="/克">/克</OPTION>
                <OPTION value="/千克">/千克</OPTION>
                <OPTION value="/磅">/磅</OPTION>
                <OPTION value="/公吨">/公吨</OPTION>
                <OPTION value="/吨(英)">/吨 (英)</OPTION>
                <OPTION value="/吨(美)">/吨 (美)</OPTION>
                <OPTION value="/毫升">/毫升</OPTION>
                <OPTION value="/公升">/公升</OPTION>
                <OPTION value="/盎司">/盎司</OPTION>
                <OPTION value="/夸脱">/夸脱</OPTION>
                <OPTION value="/品脱(英)">/品脱(英)</OPTION>
                <OPTION value="/品脱(美)">/品脱(美)</OPTION>
                <OPTION value="/码">/码</OPTION>
                <OPTION value="/平方英尺">/平方英尺</OPTION>
                <OPTION value="/平方英寸">/平方英寸</OPTION>
                <OPTION value="/平方米">/平方米</OPTION>
                <OPTION value="/平方码">/平方码</OPTION>
                <OPTION value="/立方米">/立方米</OPTION>
              </SELECT></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">商品规格</td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input name="guige" id="guige" type="text" size="20" maxlength="20"></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">商品包装</td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input name="baozhuang" id="baozhuang" type="text" size="20" maxlength="20"></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">商品材料</td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input name="cailiao" id="cailiao" type="text" size="20" maxlength="20"></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">商品产地</td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input name="chandi" id="chandi" type="text" size="20" maxlength="20"></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">商品认证</td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input name="renzheng" id="renzheng" type="text" size="20" maxlength="20"></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">交货时间&nbsp;<font color="#FF0000">*</font></td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input name="jiaohu" id="jiaohu" type="text" size="20" maxlength="20"></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">付款方式&nbsp;<font color="#FF0000">*</font></td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input name="paytype" id="paytype" type="text" size="20" maxlength="20"></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">运输方式&nbsp;<font color="#FF0000">*</font></td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input name="yunshu" id="yunshu" type="text" size="20" maxlength="20"></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">运费承担&nbsp;<font color="#FF0000">*</font></td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input name="yunfei" id="yunfei" type="text" size="20" maxlength="20"></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">活动</td>
            <td height="25" align="left" bgcolor="#F9F9F9"><input type="radio" name="is_huodong" value="1">是<input name="is_huodong" type="radio" value="0" checked>否&nbsp;&nbsp;&nbsp;<font color="#FF0000">选择活动，下面活动价格和活动时间必须填写</font></td>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">活动价格</td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input name="hd_price" id="hd_price" type="text" size="20" maxlength="20">
            元（请写数字）</TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">活动时间</td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input name="hd_time" id="hd_time" type="text" size="20" maxlength="20" onClick="setDay(this);" value="<?=date("Y-m-d ",strtotime("+30day"))?>"> 
            时间格式：0000-00-00 (默认时间一个月,活动最长时间为3个月)</TD>
          </TR>			  		  		  
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">&nbsp;</td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input type="submit" value="提交"><INPUT type="hidden" value="ok" name="act_tj"></TD>
          </TR>
 </form>                
</TABLE>
<input type="hidden" value='<?=date("Y-m-d",strtotime("+90 day"))?>' id="thidden" />
</div>
<div class="onl"></div>
<?php include("../inc/foot.php");?>

</div>
</body>
</html>
<script language="javascript">
function $(id){
return document.getElementById(id);
}
function checkform(){
   if($("p_title").value==""){
      alert("标题不能为空");
      $("p_title").focus();
      return false;
   }
   if($("catalog_1").value==""){
      alert("请选择目录");
      $("catalog_1").focus();
      return false;
   }
   if($("catalog_2").value==""){
      alert("请选择二级目录");
      $("catalog_2").focus();
      return false;
   }

   if($("info").value==""){
      alert("描述不能为空");
      $("info").focus();
      return false;
   }
   
   if($("pinpai").value==""){
      alert("商品品牌不能为空");
      $("pinpai").focus();
      return false;
   }  
   if($("xinghao").value==""){
      alert("商品型号不能为空");
      $("xinghao").focus();
      return false;
   }   
   if($("price").value==""){
      alert("批发价格不能为空");
      $("price").focus();
      return false;
   }
   if($("shuliang").value==""){
      alert("批发数量不能为空");
      $("shuliang").focus();
      return false;
   }
   if($("shuliang2").value==""){
      alert("请选择单位");
      $("shuliang2").focus();
      return false;
   }
   if($("jiaohu").value==""){
      alert("交货时间不能为空");
      $("jiaohu").focus();
      return false;
   }  
   if($("paytype").value==""){
      alert("付款方式不能为空");
      $("paytype").focus();
      return false;
   } 
   if($("yunshu").value==""){
      alert("运输方式不能为空");
      $("yunshu").focus();
      return false;
   }
   if($("yunfei").value==""){
      alert("运费承担不能为空");
      $("yunfei").focus();
      return false;
   }
   if($("is_huodong").checked)
   {
      if($("hd_price").value=="")
	  {
	    alert("活动价格不能为空");
        $("hd_price").focus();
        return false;
	  }
	  
	  if($("hd_time").value=="")
	  {
	    alert("活动时间不能为空");
        $("hd_time").focus();
        return false;
	  }
	  else
	  {  
			val=$("hd_time").value;
			t=$("thidden").value;
			if(t<val)
			{
				alert("活动时间最长为3个月,请重新选择");
        		$("hd_time").focus();
        		return false;
			}
	  }
   }   
           
      
}
</script>
